{include file="public/header" /}
<link rel="stylesheet" type="text/css" href="/static/admin/webupload/webuploader.css">
<link rel="stylesheet" type="text/css" href="/static/admin/webupload/style.css">
<style>
.file-item{float: left; position: relative; width: 110px;height: 110px; margin: 0 20px 20px 0; padding: 4px;}
.file-item .info{overflow: hidden;}
.uploader-list{width: 100%; overflow: hidden;}
</style>
<style>
	.layui-upload-list{display: flex;flex-wrap:wrap;}
	.layui-upload-list div{display: inline-block;text-align: center;cursor: pointer;flex-direction: column;display: flex;margin-right: 8px;}
	.layui-upload-list div img{height:100px;}
	.layui-upload-list div video{height:100px;}
	.layui-upload-list div span{display: block;}
	
	#div-slide_show_pic{display:flex;flex-wrap:wrap;}
	.item-img {
		flex-direction: column;
		display: flex;
		margin-right: 18px;
		margin-bottom:17px;width:12%;text-align:center;
	}
	.item-img img{max-width: 100%;}
	.delMultipleImgs4{text-align:center;}
</style>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>添加/编辑</h5>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                        <a class="dropdown-toggle" data-toggle="dropdown" href="form_basic.html#">
                            <i class="fa fa-wrench"></i>
                        </a>
                        <a class="close-link">
                            <i class="fa fa-times"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content">
                    <form class="form-horizontal m-t" name="edit" id="edit" method="post" action="edit_article">
                    <input type="hidden" name="id" value="{$info.id??''}">
                    <input type="hidden" name="course_id" value="{$course_id??''}">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">标题：</label>
                            <div class="input-group col-sm-4">
                                <input id="title" type="text" class="form-control" name="title" value="{$info.title??''}">
                            </div>
                        </div>
                        
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-3">
                                <button class="btn btn-primary" type="submit" id="c_s"><i class="fa fa-save"></i> 保存</button>&nbsp;&nbsp;&nbsp;
                                <a class="btn btn-danger" href="javascript:history.go(-1);"><i class="fa fa-close"></i> 返回</a>
                            </div>
                        </div>
                    </form>
                </div>
            </div>

        </div>
    </div>
</div>
  {include file="public/footer" /}

    <link rel="stylesheet" href="/static/admin/css/layui.css" media="all"/>
<script type="text/javascript" src="/static/admin/webupload/webuploader.min.js"></script>
<!--<script type="text/javascript" src="/static/admin/js/wangEditor.min.js"></script>-->
<script type="text/javascript" src="/static/admin/js/layui.js"></script>
<script type="text/javascript">

 /*   var E = window.wangEditor;
    var editor = new E('#div1');
    editor.customConfig.uploadFileName = 'file';//要传参数名
    editor.customConfig.showLinkImg = false;
    editor.customConfig.uploadImgServer = "{:url('Upload/uploads')}";
    editor.customConfig.uploadImgHooks = {
        //图片上传并返回结果，自定义插入图片的事件
        customInsert: function (insertImg, result, editor) {
            if (result.status){
                var url = result.url;
                insertImg(url)
            }else{
                alert('上传失败')
            }
        }
    };
    editor.create();*/

layui.use(['upload'], function () {
	var upload = layui.upload;
    
});

    //提交按钮添加点击事件，获取编辑器的内容
    /*$('#c_s').click(function () {
        $('#myEditor').val();
        $('#myEditor').val(editor.txt.html());
    });*/


    $(function(){
        $('#edit').ajaxForm({
            beforeSubmit: checkForm, // 此方法主要是提交前执行的方法，根据需要设置
            success: complete, // 这是提交后的方法
            dataType: 'json'
        });

        function checkForm(){
            if( '' == $.trim($('#title').val())){
                layer.msg('标题不能为空', {icon: 5,time:1500,shade: 0.1}, function(index){
                    layer.close(index);
                });
                return false;
            }
            

     }

        function complete(data){
            if(data.code == 1){
                layer.msg(data.msg, {icon: 6,time:1500,shade: 0.1}, function(index){
                    layer.close(index);
                    window.location.href="{:url('course_unit/index')}?course_id={$course_id}";
                });
            }else{
                layer.msg(data.msg, {icon: 5,time:1500,shade: 0.1}, function(index){
                    layer.close(index);
                });
                return false;
            }
        }

    });


    //IOS开关样式配置
   var elem = document.querySelector('.js-switch');
        var switchery = new Switchery(elem, {
            color: '#1AB394'
        });
    var config = {
        '.chosen-select': {},                    
    }
    for (var selector in config) {
        $(selector).chosen(config[selector]);
    }



</script>
</body>
</html>
